<script setup>
import { ref, reactive, getCurrentInstance, onMounted, watch, render } from "vue"
import { CirclePlus } from '@element-plus/icons-vue';
import {mw_throttle} from '@/utils'

const instance = getCurrentInstance()
const _this = instance.appContext.config.globalProperties //vue3获取当前this
const storage = _this.$utils.storage;

import { globalStore } from "@/store/global";
const globalVue = globalStore();
const isEdit = ref(globalVue.userInfo?.role != 2 || false); 

// 组件中使用，接收传参的
let propsData = defineProps({
  searchForm: Object,
  selectVehicle: {
    type: Array,
    default: []
  },
  selectGender: {
    type: Array,
    default: []
  },
})
// 组件中使用，接收事件的
const emits = defineEmits(['onSearch', 'addPeople']);

const onSubmit = () => {
  function _submit(){
    emits('onSearch')
  }
  mw_throttle(_submit, 1000)
}
const addPeoples = () => {
  function _submit(){
    emits('addPeople')
  }
  mw_throttle(_submit, 1000)
}
</script>

<template>
  <el-form :inline="true" :model="searchForm" class="form_search_table">
    <el-form-item label="Package ID">
      <el-input v-model="searchForm.packageId" placeholder="Search for package ID" @keyup.enter="onSubmit" clearable />
    </el-form-item>
    <el-form-item label="Name">
      <el-input v-model="searchForm.name" placeholder="Search for name" @keyup.enter="onSubmit" clearable />
    </el-form-item>
    <el-form-item label="Version">
      <el-input v-model="searchForm.version" placeholder="Search for version" @keyup.enter="onSubmit" clearable />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">Query</el-button>
      <div class="event_btn">
        <el-button type="primary" v-if="globalVue.isTourist" :icon="CirclePlus" @click="addPeoples">Add Package</el-button>
      </div>
    </el-form-item>
  </el-form>
</template>